#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
AC_INIT([trayinfo], [0.4-svn], [kodest@gmail.com])
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADER([config.h])

AC_LIBTOOL_DLOPEN
AC_WITH_LTDL
AC_DISABLE_STATIC

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB

AM_PROG_CC_C_O
AC_PROG_LIBTOOL

# Checks for libraries.
AC_LIB_LTDL
dnl AC_CHECK_LIB([ssl], [SSL_read], [AC_DEFINE(HAVE_LIBSSL, 1, [We have ssl]) enable_ssl=yes], [enable_ssl=no])

AC_ARG_WITH([ssl], [AS_HELP_STRING([--without-ssl], [disable support for ssl])], [], [with_ssl=yes])
          
LIBSSL=
AS_IF([test "x$with_ssl" != xno],
  [AC_CHECK_LIB(
    [ssl],
    [SSL_read],
    [AC_SUBST([LIBSSL], ["-lssl"]) AC_DEFINE([HAVE_LIBSSL], [1], [Define if you have libssl])],
    [AC_MSG_FAILURE([ssl test failed (--without-ssl to disable)])]
  )])

TRAYINFO_MODULES="acpibatt acpitemp cpu ldavg mem mhz mpd netspeed sensor time"
AS_IF([test "x$with_ssl" != xno], [TRAYINFO_MODULES="$TRAYINFO_MODULES gmail"])
AC_SUBST(TRAYINFO_MODULES)

# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/socket.h sys/time.h termios.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_HEADER_STDBOOL
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_HEADER_TIME
AC_STRUCT_TM

# Checks for library functions.
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_STRFTIME
AC_FUNC_STRTOD
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([gettimeofday memchr memmove memset select socket strcasecmp strchr strdup strrchr strstr])

AC_CONFIG_FILES([Makefile
                 doc/Makefile
                 src/Makefile
                 src/modules/Makefile
                 src/modules/acpibatt/Makefile
                 src/modules/acpitemp/Makefile
                 src/modules/cpu/Makefile
                 src/modules/gmail/Makefile
                 src/modules/ldavg/Makefile
                 src/modules/mem/Makefile
                 src/modules/mhz/Makefile
                 src/modules/mpd/Makefile
                 src/modules/netspeed/Makefile
                 src/modules/sensor/Makefile
                 src/modules/time/Makefile])
AC_OUTPUT


echo "Enabled modules: $TRAYINFO_MODULES"
